Repository navigation
Conversation
|
This issue is currently awaiting triage. If SIG Autoscaling contributors determines this is a relevant issue, they will accept it by applying the The DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
97188dd to
bb0b698
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: shaikenov The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
bb0b698 to
d24246a
Compare
…rator Removes getRemainingPodsConsideringSkippedNodeGroups and findSkippedNodeGroupsSatisfyingPodPredicates from ScaleUpOrchestrator so that skipped node group predicate checks do not block the main scale-up loop. GetRemainingPods now only takes the pod groups and the skipped node groups, and every remaining pod is reported with the full set of skipped node groups. TestScaleUpSimulationForSkippedNodeGroups is removed with it. With this commit alone ScaleUpSimulationForSkippedNodeGroupsEnabled has no effect; the next two commits re-add the attribution asynchronously with a background Evaluator and ScaleUpStatusProcessor.
Adds Evaluator and NewEvaluatorFrameworkHandle in pkg/processors/skippednodegroups: a background goroutine with its own scheduler framework.Handle and a 1-node PredicateSnapshot, so that skipped node group predicate checks never run on the main loop. Key details: - Each job evaluates all current (pod group, skipped node group) pairs on a private 1-node snapshot and publishes verdicts as a whole, keyed by (pod UID, node group id). - NewEvaluatorFrameworkHandle builds a dedicated framework handle on the shared informer factory with a distinct profile name so plugins never share DelegatingLister or collide on informer indexers. - PairsPerSecond (20k by default) throttles the worker, and inter-pod affinity is stripped from the evaluated pod copy since it cannot be evaluated against a lone template node. - ScaleUpStatusProcessor and AutoscalerBuilder wiring are added in the next commit; incremental caching and job merging follow in subsequent commits.
Adds ScaleUpStatusProcessor in pkg/processors/skippednodegroups and wires it with Evaluator in AutoscalerBuilder. On each scale-up loop, Process gathers skipped node group templates from TemplateNodeInfoRegistry, groups unschedulable pods into equivalence groups bounded by MaxPairsPerLoop (200k by default), looks up the Evaluator's latest verdicts, schedules the current pairs for background evaluation, and moves incompatible skipped node groups to RejectedNodeGroups while keeping pairs without a verdict yet in SkippedNodeGroups. Key wiring and safety details: - Composed before CapacityBuffer's FakePodsScaleUpStatusProcessor and after ProactiveScaleup's podinjection filter so CapacityBuffer events keep attributed reasons while injected pods are filtered out beforehand. - Evaluator.Run starts only after AutoscalerBuilder finishes cache sync. - TemplateNodeInfoRegistry misses do not fall back to cloud-provider ng.TemplateNodeInfo calls on the main loop. - scaleUp:skippedNodeGroupsSimulation now measures the processor's work on the main loop instead of the synchronous predicate checks. Known limitations of this version: - When several statuses are processed per loop with different pods (e.g. one per scale-up salvo iteration), a pending job is replaced by the newer one and every finished job replaces all published verdicts, so verdicts of pods that only appear in an earlier status of the loop can be lost. Fixed by the follow-up commits that cache verdicts and merge jobs. - DRA and CSINode-aware scheduling are not enabled on the evaluator, so pods using DRA can be attributed incorrectly and CSI volume limits are not checked. Both are handled in a follow-up change.
Makes the async skipped node groups Evaluator incremental: verdicts are kept
in a dedicated verdictCache (verdict.go) across loops and the worker only
evaluates (pod group, skipped node group) pairs that are not cached yet,
instead of re-evaluating every pair on every loop.
- Lookup: the main loop resolves each pair from the cache and hands only
unknown pairs (never evaluated, or expired) to the worker. Lookups are
read-only.
- Keys: (pod UID, node group id). A group's verdict is the cached verdict of
any of its pods, so new replicas of a known group are served right away.
- Expiry: every verdict is dropped after VerdictTTL (30 minutes by default)
and evaluated again on the next loop that asks for it, so changes the key
does not capture (node group template updates, informer-backed predicate
inputs such as PVC/PV binding state) are picked up within the TTL. Until
then a verdict can be stale, and an expired verdict is unknown (the node
group is left skipped) until it has been evaluated again. VerdictTTL <= 0
disables expiry.
- Worker: skips pairs that became freshly cached while queued and stores
each pod-free verdict as soon as it is computed, instead of publishing a
whole job at once. A newer job still replaces a pending one, but the
replaced pairs stay unknown and are requested again by the next loop.
- Memory bounds: expired verdicts are swept (both periodically in Run and
between jobs in ProcessPendingNow). The sweep is what drops verdicts of
pods that are gone or of node groups that are no longer skipped, since
nothing looks those up again. Shrinking far below peak triggers map
compaction.
- clustersnapshot: adds WithoutPod, which copies a SchedulingError without
the pod it was created for, and lets schedulingError.Error() handle a nil
pod, so cached verdicts neither pin deep-copied exemplar pods in memory
nor name them in Error().
Known limitations of this version:
- A newer job replaces the pending one, so when several statuses are
processed per loop (e.g. one per scale-up salvo iteration), pairs that
only appear in an earlier status can keep being replaced while the worker
is busy. Fixed by the follow-up that merges jobs.
- Verdicts are keyed by pod UID. A follow-up change keys them by pod group
signature, which fixes:
- cache size and main-loop lookups scale with pending pods x skipped node
groups rather than pod groups;
- a group's verdict is lost once every pod it was stored for is gone,
e.g. for Jobs that keep recreating pods;
- mutable scheduling fields (e.g. added tolerations) are only picked up
once the verdict expires.
Several statuses can be processed per loop (e.g. one per scale-up salvo iteration) with different pods. While a newer job replaced the pending one, pairs that only appear in an earlier status could keep being replaced while the worker was busy, so jobs are now merged. - Hand-off: a new job is merged behind any existing pending job in FIFO order (deduplicated by (pod UID, node group id), bounded by MaxPairsPerLoop) under e.mu instead of replacing it. Templates are merged by node group, keeping the existing pending job's template NodeInfo. Pairs cut off by MaxPairsPerLoop stay unknown and are requested again by the next loop. - Worker: finishes the currently running job to completion before picking up the next pending job, and logs enqueued/finished job counts and cache size. - Tests: merging pending jobs, overlapping salvo statuses, and MaxPairsPerLoop bounding on merged jobs.
d24246a to
b94ca3a
Compare
|
Apologies for the huge diff here :( I tried to limit the change as much as possible, but to extensively cover the basic scenario. Tried to have the change splitted in isolated commits, so it is easier to review - hope it helps :). There is a list of open points that are not covered in this PR, but will be covered in the follow up (such as better caching for pod group signatures, CSI/DRA nodes, metrics, etc - PTAL at the description). /assign @mtrqq |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Extract the skipped NG simulation into a separate processor which will be run in a separate goroutine unblocking the CA critical scale up path.
As of now skipped NG simulation (ref: kubernetes/autoscaler#9346) is run in the scale up orchestrator as a part of general scale up simulation which has big impact on the scale up time and the overall CA loop performance.
Which issue(s) this PR fixes:
Addresses #289
Special notes for your reviewer:
I tried to structure the chain in the following way so it is easier to review:
Remove synchronous skipped NG simulation from
ScaleUpOrchestrator-Returns
ScaleUpOrchestratorto its pre-feature behavior so skipped node group predicate checks never block the main scale-up loop.Add background
Evaluatorfor skipped node group predicate checks -Introduces the background worker goroutine with its own dedicated
framework.Handle(distinct scheduler profile name on the shared informer factory) and a 1-nodePredicateSnapshotso each skipped node group is evaluated in isolation off the main loop. This starts with the simplest model: every job evaluates all current(pod group, skipped NG)pairs and publishes verdicts as a whole, keyed by(pod UID, node group ID), with rate limiting (PairsPerSecond) and inter-pod affinity stripped.Add async
ScaleUpStatusProcessorand wire it inAutoscalerBuilder-Wires
ScaleUpStatusProcessorinto the scale-up status processing chain (afterproactive-scaleup's pod-injection filter and beforeCapacityBuffer's fake-pod processor) and startsEvaluator.Runafter cache sync. On each loop,Processresolves templates fromTemplateNodeInfoRegistry(no synchronous cloud-provider fallback), bounds work byMaxPairsPerLoop, looks up the latest verdicts, schedules the current pairs, and moves incompatible skipped node groups toRejectedNodeGroups(leaving unknown pairs conservatively inSkippedNodeGroups).Cache
(pod, skipped NG)verdicts across loops -Makes evaluation incremental with a TTL-backed
verdictCache(DefaultVerdictTTL = 30m), periodic/between-job expiry sweeps with map compaction, andclustersnapshot.WithoutPodso cachedSchedulingErrors do not pin deep-copied exemplar pods in memory. Only unknown or expired pairs are handed to the worker, and pairs that became freshly cached while queued are skipped.Merge pending jobs instead of replacing them -
Multiple
ScaleUpStatuses can be processed per loop (e.g. across scale-up salvo iterations or async node group initializers) with different pod sets. Instead of overwritingpending, incoming jobs are merged behind any existing pending job in FIFO order (deduplicated by(pod UID, node group ID)and bounded byMaxPairsPerLoop), while the currently running job finishes to completion before the worker drains the merged pending job.Open points:
DefaultMaxPairsPerLoopandDefaultPairsPerSecond- via CLI flags preferrably.All of these will be addressed in the follow ups.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: